/* GUI CONVERTED from rprsrp03.p (converter v1.75) Tue Aug 22 11:49:24 2000 */
/* rprsrp03.p - PRODUCT LINE RESOURCE LOAD SUMMARY REPORT               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/* All rights reserved worldwide.  This is an unpublished work.        */
/* web convert rprsrp03.p (converter v1.00) Fri Oct 10 13:57:19 1997 */
/* web tag in rprsrp03.p (converter v1.00) Mon Oct 06 14:17:45 1997 */
/*F0PN*/ /*K1DC*/ /*                                                    */
/*V8:ConvertMode=FullGUIReport                                 */
/* REVISION: 1.0     LAST MODIFIED: 05/13/86    BY: emb         */
/* REVISION: 4.0     LAST MODIFIED: 02/24/88    BY: wug *A175*      */
/* REVISION: 4.0     LAST MODIFIED: 06/20/89    BY: emb *A748*      */
/* REVISION: 4.0     LAST MODIFIED: 02/22/90    BY: wug *B583*      */
/* REVISION: 6.0     LAST MODIFIED: 06/01/90    BY: ram *D028*      */
/* REVISION: 5.0     LAST MODIFIED: 09/27/90    BY: ram *B793*      */
/* REVISION: 7.0     LAST MODIFIED: 10/11/91    BY: emb *F024*      */
/* REVISION: 7.3     LAST MODIFIED: 10/23/92    BY: ram *G231*      */
/* REVISION: 7.3     LAST MODIFIED: 10/18/94    BY: jzs *GN61*      */
/* REVISION: 8.6     LAST MODIFIED: 12/11/97    BY: bvm *K1DC*      */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0K5* Arul Victoria   */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*GN61*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rprsrp03_p_2 "Day/Week/Month"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp03_p_3 "Per Column"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp03_p_6 "Over Cap %"
/* MaxLen: Comment: */

&SCOPED-DEFINE rprsrp03_p_9 "Under Cap %"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 * &SCOPED-DEFINE rprsrp03_p_1 "Load         "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp03_p_4 "Cumulative   "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp03_p_5 "Past    "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp03_p_7 "Over/Under   "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp03_p_8 "Capacity     "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rprsrp03_p_10 "Workdays     "
 * /* MaxLen: Comment: */
 *
 *N0K5* ------------------- END   DELETE ----------------------- */

     define variable start like pq_start.
     define variable start1 like pq_start.
     define variable rsc like pq_rsc.
     define variable rsc1 like pq_rsc.
     define variable site like pq_site.
     define variable site1 like pq_site.

     define variable interval as integer extent 14.
     define variable sdate like ro_start extent 14.
     define variable load as decimal extent 14 format ">>>>,>>9".
     define variable cap as decimal extent 14 format ">>>>,>>9".
     define variable ovund as decimal extent 14 format "->>>,>>9".
     define variable cum as decimal extent 14 format "->>>,>>9".
     define variable workdays as integer extent 14 format ">>>>,>>9".
     define variable periods as integer extent 14 format ">>>>,>>9".
     define variable det_load as decimal extent 14 format ">>>>,>>9".
     define variable holiday as integer.
     define variable i as integer.
     define variable j as integer.
     define variable qty like pq_qty.
     define variable wostart as integer.
     define variable nonwdays as decimal.
     define variable elapsedays as integer.
     define variable wdays as integer.
     define variable overlap as integer.
     define variable wointerval as integer.
     define variable offset like pq_lt_off.
     define variable ltoff like pq_lt_off.
     define variable ltoffperiod as integer.
     define variable lead as integer.
     define variable dwm as character format "!(1)" label {&rprsrp03_p_2}.
     define variable idays as integer format ">>>>>9" label {&rprsrp03_p_3}.
     define variable monthend as integer.
     define variable num_intervals as integer initial 13.
     define variable period as integer.
     define variable prod_start as date.
     define variable prod_end as date.
     define variable rscde like rs_rsc.
     define variable more like mfc_logical.
     define variable upct like wc_bdn_pct label {&rprsrp03_p_9}.
     define variable opct like wc_bdn_pct label {&rprsrp03_p_6}.
     define variable printflg as character.

/*GN61 moved 1st column from 15 to 25 in frame a. (jzs) */
     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
site           colon 25
        site1          label {t001.i} colon 49
        rsc            colon 25
        rsc1           label {t001.i} colon 49 skip(1)
        start          colon 25 skip
        dwm            colon 25 skip
        idays          colon 25 skip(1)
        upct           colon 25
        opct           colon 25
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

     site = global_site.
     site1 = global_site.

/*K1DC*/ {wbrp01.i}

         
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

/*GN61      do with frame a: */

           if start = ? then start = date(month (today),1,year (today)).
           if dwm = "" then dwm = "M".
           if idays = 0 or idays = ? then idays = 1.
           if opct = ? then opct = 0.
           if upct = ? then upct = 0.

           if rsc1 = hi_char then rsc1 = "".
           if site1 = hi_char then site1 = "".

           display site site1 rsc rsc1 start dwm idays upct opct
/*GN61*/    with frame a.

/*K1DC*/      if c-application-mode <> 'web' then
              
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K1DC*/ {wbrp06.i &command = set &fields = "  site site1 rsc rsc1 start idays
             upct opct " &frm = "a"}

/*K1DC*/ if (c-application-mode <> 'web') or
/*K1DC*/ (c-application-mode = 'web' and
/*K1DC*/ (c-web-request begins 'data')) then do:

/*GN61 - moved section above bcdparming */
           if day(start) <> 1 then do:
          start = date(month (start),1,year (start)).
          display start with frame a.
           end.

           bcdparm = "".
           {mfquoter.i site   }
           {mfquoter.i site1  }
           {mfquoter.i rsc    }
           {mfquoter.i rsc1   }
           {mfquoter.i start  }
           {mfquoter.i idays  }
           {mfquoter.i upct   }
           {mfquoter.i opct   }

           if rsc1 = "" then rsc1 = hi_char.
           if site1 = "" then site1 = hi_char.
/*K1DC*/ end.

               
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



           {mfphead.i}

/*GN61      end. */

        for each rs_mstr no-lock where (rs_rsc >= rsc and rs_rsc <= rsc1)
        and rs_site >= site and rs_site <= site1:

           if opct = 0 and upct = 0 then
          printflg = "yes".
           else
          printflg = "no".

           /* COMPUTE START DATES */
           sdate[1] = min(today,start).
           {mfcsdate.i}

           /* INITIALIZE VARIABLES */
           cap = 0.
           workdays = 0.
           periods = 0.
           load = 0.
           ovund = 0.
           cum = 0.

           /* CALCULATE WORKING DAYS IN EACH INTERVAL */
           {mfcwdays.i rs_site}

           /* CALCULATE CAPACITY IN EACH INTERVAL */
           rscde = rs_rsc.
/*G231         {mfccap.i} */
/*G231*/       {mfccap.i rs_site}

           for each pq_mstr no-lock where pq_rsc = rscde
           and pq_site = rs_site:

          for each pp_plan no-lock where pp_prod_line = pq_prod_line
          and pp_site = pq_site
          and (pp_year >= year(pq_start) or pq_start = ?)
          and (pp_year <= year (pq_end) or pq_end =?):

             /* CALCULATE LOAD FOR A PRODUCT LINE PRODUCTION PLAN */
             /* INITIALIZE det_load ARRAY */
             det_load = 0.

             period_loop:
             do period = 1 to 12:

            /* CALCULATE PRODUCT LINE RESOURCE LOAD */
            {mfpqld.i}

             end.
          end.
           end.

           /* CALCULATE LOAD OVER/UNDER AND CUMULATIVE */
           do i = 1 to num_intervals:
          ovund[i] = cap[i] - load[i].
          ovund[i] = integer(ovund[i]).
          if printflg = "no" and ovund[i] <> 0 then do:
             if (opct <> 0 and ovund[i] <= -1 * cap[i] * opct / 100)
             or (upct <> 0 and ovund[i] >= cap[i] * upct / 100) then
            printflg = "yes".
          end.
          cum[i] = ovund[i].
          if i > 1 then cum[i] = cum[i] + cum[i - 1].
           end.

           if printflg = "yes" then do:
          if page-size - line-counter < 12 then page.

          display rs_rsc rs_desc no-label rs_um space(6) rs_site
          with
/*N0K5*/   frame c
             width 132 side-labels STREAM-IO /*GUI*/ .

/*N0K5* ------------------- BEGIN ADD ----------------------- */
           /* SET EXTERNAL LABELS */
           setFrameLabels(frame c:handle).
/*N0K5* ------------------- END   ADD ----------------------- */

/*N0K5* ------------------- BEGIN DELETE ----------------------- *
 *          display space(14) {&rprsrp03_p_5} sdate[2 for 12] skip
 *             space(14)     sdate[2] - 1  sdate[3] - 1  sdate[4] - 1
 *             sdate[5] - 1  sdate[6] - 1  sdate[7] - 1  sdate[8] - 1
 *             sdate[9] - 1  sdate[10] - 1 sdate[11] - 1 sdate[12] - 1
 *             sdate[13] - 1 sdate[14] - 1 skip
 *             space(14)
 *             "-------- -------- -------- -------- -------- --------"
 *             "-------- -------- -------- -------- -------- --------"
 *             "--------" skip
 *             {&rprsrp03_p_10} workdays[1 for 13] skip
 *             {&rprsrp03_p_8} cap[1 for 13] skip
 *             {&rprsrp03_p_1} load[1 for 13] skip
 *             {&rprsrp03_p_7} ovund[1 for 13] skip
 *             {&rprsrp03_p_4} cum[1 for 13] skip
 *          with frame b no-labels width 132.
 *N0K5* ------------------- END   DELETE ----------------------- */

/*N0K5* ------------------- BEGIN ADD ----------------------- */
          display space(14)
             getTermLabel("PAST",8) sdate[2 for 12] skip
             space(14)     sdate[2] - 1  sdate[3] - 1  sdate[4] - 1
             sdate[5] - 1  sdate[6] - 1  sdate[7] - 1  sdate[8] - 1
             sdate[9] - 1  sdate[10] - 1 sdate[11] - 1 sdate[12] - 1
             sdate[13] - 1 sdate[14] - 1 skip
             space(14)
             "-------- -------- -------- -------- -------- --------"
             "-------- -------- -------- -------- -------- --------"
             "--------" skip
             getTermLabel("WORKDAYS",13) format "x(13)" workdays[1 for 13] skip
             getTermLabel("CAPACITY",13) format "x(13)" cap[1 for 13] skip
             getTermLabel("LOAD",13) format "x(13)" load[1 for 13] skip
             getTermLabel("OVER/UNDER",13) format "x(13)" ovund[1 for 13] skip
             getTermLabel("CUMULATIVE",13) format "x(13)" cum[1 for 13] skip
          with frame b no-labels width 132 STREAM-IO /*GUI*/ .
/*N0K5* ------------------- END   ADD ----------------------- */

           end.

           
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/


        end.

        
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

     end.

/*K1DC*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" site site1 rsc rsc1 start idays upct opct  "} /*Drive the Report*/
